<gm:page title="News Map">
  
<style>
a:link {color: #BC7228;text-decoration: none;}
a:hover {color: #3B4F6A;text-decoration: none;}
a:visited {color: #BC7228;text-decoration: none;}
a:active {color: #3B4F6A;text-decoration: none;}
</style>
  
<link href="" rel="stylesheet" type="text/css" />
<div style="width:980px" align="left">
<gm:tabs target="myContainer"/>
<gm:container id="myContainer">
<gm:section id="topNews" title="地区头条新闻">

<table width="900">
<tr valign="top">

<td class="mainPanel"> <gm:map id="mapNews" data="${dataLocation}" latref="atom:lat"
lngref="atom:long" infotemplate="templateMap">
<gm:handleEvent src="mapNews" event="select"
execute="updateFeed();" />
<gm:handleEvent src="listNewsAll" />
<gm:handleEvent src="myList" event="select"/>
</gm:map> <gm:list id="listNewsAll" data="http://xml.weather.yahoo.com/forecastrss?u=c&p=CHXX0008" pagesize="10" template="templateListNews">
<gm:handleEvent event="repaint" execute="updateMap();" />
</gm:list>
</td>
<td width="80" align="right">
<gm:list id="myList" data="${dataLocation}" >
</gm:list>
</td>
</tr>
</table>
</gm:section>


<gm:section id="about" title="关于我们">
<table align="center">
<tr><td valign="top">我是小锴，欢迎您的访问！</td>
</tr>
<tr><td>email:raokaishiwo@gmail.com</td></tr>
<table>
</gm:section>


<!--<gm:section id="AllNews" title="更多地区新闻">
<td style="width:auto" valign="top">
<gm:list id="listNewsAll" data="http://news.baidu.com/n?cmd=7&loc=0&name=%B1%B1%BE%A9&tn=rss" pagesize="5" >
<gm:handleEvent event="repaint" execute="updateMap();" />
</gm:list></td>-->







</gm:container>

</div>

<gm:template id="templateListNews">

<table class="blue-theme" border="0" cellpadding="0" cellspacing="0">


<tbody repeat="true">

</tbody>

</table>
</gm:template>

<gm:template id="templateMap">
<div id="td_newsList" style="width:300px;height:200px" align="left">

</div>
</gm:template>


<!-- 地理译码 -->
<gm:data id="dataLocation">
<atom:feed>
<atom:entry>
<atom:id>1</atom:id>
<atom:title>北京</atom:title>
<atom:lat>39.9</atom:lat>
<atom:long>116.4</atom:long>
</atom:entry>
<atom:entry>
<atom:id>2</atom:id>
<atom:title>上海</atom:title>
<atom:lat>31.2</atom:lat>
<atom:long>121.4</atom:long>
</atom:entry>

</atom:feed>
</gm:data>



<script>


var flag;
var listModule;


function updateFeed(){



var titleGPath = new GPath("atom:title");



var entry = google.mashups.getObjectById('mapNews').getSelectedEntry();

if (entry == null) { return; }

var title= titleGPath.getValue(entry);



var rssUrl;

//if(title=="北京"){

//rssUrl = "http://news.baidu.com/n?cmd=7&loc=0&name=%B1%B1%BE%A9&tn=rss";

//}
//else if(title=="上海"){

//rssUrl = "http://news.baidu.com/n?cmd=7&loc=2354&name=%C9%CF%BA%A3&tn=rss";

//}

switch(title){

case "北京":
{rssUrl = "http://xml.weather.yahoo.com/forecastrss?u=c&p=CHXX0008";break;}
case "上海":
{rssUrl = "http://xml.weather.yahoo.com/forecastrss?u=c&p=CHXX0093";break;}
default :
{rssUrl = "http://xml.weather.yahoo.com/forecastrss?u=c&p=CHXX0008";break;}
}


listModule = google.mashups.getObjectById('listNewsAll');

listModule.setData(rssUrl );




}

function updateMap(){

//if(flag==0){

//flag = 1;

//return;

//}


var titleGPathForMap = new GPath("atom:title");

//var linkGPathForMap = new GPath("atom:link/@href");

var output = "";

var size=listModule.getData().size()



var newsTitle;

var newsLink;

for (var i = 0; i < size; i++) {

newsTitle = titleGPathForMap .getValue(listModule.getData().entryAt(i));

newsLink = linkGPathForMap .getValue(listModule.getData().entryAt(i));



output +=(i+1)+" "+ "<a href=" + newsLink + " target=_blank>" + newsTitle + "</a><br>";

}




document.getElementById("td_newsList").innerHTML = output;

}





</script>


</gm:page>